package com.bwie.controller;

import com.bwie.pojo.Order;
import com.bwie.pojo.ProdInfo;
import com.bwie.service.OrderService;
import com.bwie.service.impl.OrderServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 订单表(tb_order)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/product/product")
@Api(tags = "订单管理")
public class OrderController {
    /**
     * 服务对象
     */
    @Autowired
    private OrderService orderService;


    /**
     * @author: 鑫仔
     * @description: 获取订单列表
     * @params: []
     * @return: com.bwie.utils.R
     * @date: 2025/7/23 18:53
     */
    @ApiOperation("订单列表")
    @PostMapping("getOrderList")
    public R getOrderList(
            @RequestBody PageInfoVo pageInfoVo
    ) {
        return orderService.getOrderList(pageInfoVo);
    }

    /**
     * @author: 鑫仔
     * @description: 导出Excel
     * @params: [java.lang.Integer]
     * @return: void
     * @date: 2025/7/23 19:13
     */
    @ApiOperation("导出Excel")
    @GetMapping("exportOrder/{userId}")
    public void exportOrder(
            @PathVariable(name = "userId") Integer userId
    ) {
        orderService.exportOrder(userId);
    }

    /**
     * @author: 鑫仔
     * @description: 批量删除订单
     * @params: [java.util.List<java.lang.Integer>]
     * @return: com.bwie.utils.R
     * @date: 2025/7/23 20:53
     */
    @ApiOperation("批量删除订单")
    @PostMapping("deleteBatchOrder")
    public R deleteBatchOrder(
            @RequestBody List<Integer> ids
    ) {
        return orderService.deleteBatchOrder(ids);
    }

    /**
     * @author: 鑫仔
     * @description:   添加订单
     * @params: [java.util.List<com.bwie.pojo.ProdInfo>]
     * @return: com.bwie.utils.R
     * @date: 2025/7/23 21:23
     */
    @ApiOperation("添加订单")
    @PostMapping("addOrder")
    public R addOrder(
            @RequestBody List<ProdInfo> prodInfo
    ) {
        return orderService.addOrder(prodInfo);
    }

}
